
import java.util.*;

public class Solution {


    public int fanZhuan(int x) {
        int a = 0, b = 0;
        while (x != 0) {
            a = x % 10;
            x /= 10;
            b = b * 10 + a;
            if (b > Integer.MAX_VALUE || b < Integer.MIN_VALUE)
                return 0;
        }
        return b;
    }

    public boolean isPalindrome(int x) {
        if (x < 0)
            return false;
        if (x % 10 == 0)
            return false;
        int a = 0, b = 0, t = x;
        while (x > 0) {
            a = x % 10;
            x /= 10;
            b = b * 10 + a;
            if (b > Integer.MAX_VALUE || b < Integer.MIN_VALUE)
                return false;
        }
        return b == t;
    }

    public List<List<Integer>> fourSum(int[] nums, int target) {


        return null;
    }

    public void nextPermutation(int[] nums) {
        int n = nums.length;
        Map<Integer, Integer> map = new HashMap<>();
        int sum = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (map.get(j) == null) {
                    map.put(j, i);
                    break;
                }
            }
        }
        System.out.println(map);
    }

    int ding = 0, now = 0;

    public void temp(HashMap<Integer, Integer> map, int dep, int n, int sum, int[] nums) {
        HashMap<Integer, Integer> t = (HashMap<Integer, Integer>) map.clone();
        if (dep == n) {
            if (sum > ding && sum < now)
                ding = sum;
        }
        for (int i = 0; i < n; i++) {
            if (t.get(i) == null) {
                t.put(i, dep);
                sum += nums[i];
                temp(t, dep + 1, n, sum, nums);
                t.remove(i);
            }
        }
    }

    public void getPermutation(List<Map<Integer, Integer>> list, HashMap<Integer, Integer> map, int dep, int n) {
        HashMap<Integer, Integer> t = (HashMap<Integer, Integer>) map.clone();
        if (dep == n) {
            list.add(t);
            return;
        }
        for (int i = 0; i < n; i++) {
            if (t.get(i) == null) {
                t.put(i, dep);
                getPermutation(list, t, dep + 1, n);
                t.remove(i);//重要
            }
        }
    }

    public boolean isMatch(String s, String p) {
        if (s.equals("") && !p.equals(""))
            return false;
        if (!s.equals("") && p.equals(""))
            return false;
        char[] c1 = s.toCharArray();
        char[] c2 = p.toCharArray();
        if (c1[0] == '*') return false;
        int j = 0;
        for (int i = 0; i < s.length(); i++) {
            if (j >= p.length())
                return false;
            if (c2[j] == '.') {
                if (j + 1 < p.length() && c2[j + 1] == '*') {
                    if (j + 2 < p.length())
                        return true;
                    boolean flag = false;
                    while (i < s.length()) {
                        flag = flag || isMatch(s.substring(i), p.substring(j + 2));
                        i++;
                    }
                    return flag;
                }
                j++;
                continue;
            }
            if (c2[j] == '*') {
                if (c2[j - 1] == '*')
                    return false;
                if (isMatch(s.substring(i), p.substring(j + 1)))
                    return true;
                boolean flag = false;
                while (c1[i] == c2[j - 1]) {
                    i++;
                    flag = flag || isMatch(s.substring(i), p.substring(j + 1));
                }
                return flag;
            }
            if (c1[i] != c2[j]) {
                if (j + 2 < p.length() && c2[j + 1] == '*')
                    return isMatch(s.substring(i), p.substring(j + 2));
                return false;
            }

            j++;
        }

        return true;
    }

    public List<List<Integer>> threeSum(int[] nums) {
        List<List<Integer>> res = new ArrayList<>();
        Arrays.sort(nums);
        int m = nums.length;
        if (m < 3)
            return res;
        for (int i = 0; i < m - 2; i++) {
            while (i > 0 && nums[i] == nums[i - 1] && i < m-1)
                i++;
            if(i>m-3)
                break;
            int target = -nums[i];
            int l = i + 1, r = m - 1;
            while (l < m-1 && l < r) {
                if (nums[l] + nums[r] < target) {
                    l++;
                } else if (nums[l] + nums[r] > target) {
                    r--;
                } else {
                    List<Integer> list = new ArrayList<>();
                    list.add(nums[i]);
                    list.add(nums[l]);
                    list.add(nums[r]);
                    res.add(list);
                    l++;
                    while (l < m -1&&nums[l] == nums[l - 1])
                        l++;
                }
            }
        }
        System.out.println(res);
        return res;
    }
    public List<List<Integer>> threeSum2(int[] nums) {
        List<List<Integer>> res = new ArrayList<>();
        Arrays.sort(nums);
        int m = nums.length;
        if (m < 3)
            return res;
        for (int i = 0; i < m - 2; i++) {
            while (i > 0 && nums[i] == nums[i - 1] && i < m-1)
                i++;
            if(i>m-3)
                break;
            int target = -nums[i];
            HashMap<Integer,Integer>map=new HashMap<>();
            for(int j=i+1;j<m;j++){
                if(j>1&&nums[j]==nums[j-1]&&j<m-2)
                    continue;
                if(map.get(target-nums[j])==null){
                    map.put(nums[j],j);
                }
                else {
                    List<Integer> list = new ArrayList<>();
                    list.add(nums[i]);
                    list.add(nums[j]);
                    list.add(nums[map.get(target-nums[j])]);
                    res.add(list);
                }
            }
        }
        System.out.println(res);
        return res;
    }
    public boolean isValid(String s) {
        int m=s.length();
        if(m%2!=0)
            return false;
        char []cs=new char[m/2];
        int ding=-1;
        for(int i=0;i<m;i++){
            char temp=s.charAt(i);
            if(temp=='('||temp=='['||temp=='{'){
                cs[++ding]=temp;
            }
            else if(ding<0||ding>=m/2)
                return false;
            else if(temp==')'&&cs[ding]=='(')
                ding--;
            else if(temp==']'&&cs[ding]=='[')
                ding--;
            else if(temp=='}'&&cs[ding]=='{')
                ding--;
            else return false;
        }

        return ding==-1;
    }
    public static void main(String[] args) {
        int a = -101;
        System.out.println(a % 10);

    }
}
